<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>帖子评论</title>
    <link rel="stylesheet" href="${base}/layui/css/layui.css">
    <link rel="stylesheet" href="${base}/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${base}/css/admin.css">
    <style>
    	.layui-bg-black{        width: 200px;height: 136px;margin-right: 30px;float: left;text-align: center;font-size: 33px;color: #000000!important;padding-top: 30px;}
    	.hide {display: none;}
    	.checkbox{display: inline-block;}
    	.layui-form-item{font-size: 18px;}
    	.width100 {width: 100px; margin-right: 30px;float: left;}
    	.width180 {width: 180px; margin-right: 20px;float: left;}
    	.layui-input { display: inline-block; }
    	.layui-table td.content {width: 160px;}
    </style>
</head>
<body class="layui-layout-body" style="overflow:scroll;">
<#include "/common/left.flt">	
<div class="layui-main" style="position: absolute;left: 204px;top: 4px; width: calc(100% - 210px);" >
<fieldset class="layui-elem-field layui-field-title" >
  <legend>操作提示</legend>
</fieldset>
<div class="layui-form hide" id="discuss" style="padding-top:20px;padding-right:20px;">
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">回复内容</label>
    <div class="layui-input-block">
      <input name="content" id="content" placeholder="请输入内容" class="layui-input" />
    </div>
  </div>
</div>
<blockquote class="layui-elem-quote layui-quote-nm">
 	<form action="${base}/card_list/discuss_list" method="post" id="dataForm">
        <input type="hidden" id="page" name="page" value="1"/>
 		<div class="layui-input-inline" style="margin-top: 10px;" >
		      <label class="layui-form-label">用户类别:</label><select name="is_true" id="is_true" class="width100 layui-select">
 				<option value=""></option>
 				<option value='1'>A类</option>
				<option value='2'>B类</option>
				<option value='3'>C类</option>
				<option value='4'>D类</option>
                <option value='100'>灰名单</option>
		      </select>
		      <label class="layui-form-label">性别:</label><select name="sex" id="sex" class="width100 layui-select">
 				<option value=""></option>
 				<option value="1">男</option>
                <option value="2">女</option>
                <option value="3">CD</option>
                <option value="4">FtM</option>
                <option value="5">MtF</option>
		      </select>
		      <label class="layui-form-label">类型:</label><select name="type" id="type" class="width100 layui-select">
 				<option value="0">评论</option>
                <option value="1">回复</option>
		      </select>
 		</div>
 		<div class="layui-input-inline" style="margin-top: 10px;" >
 			<input placeholder="帖子id" name ="card_id" class="width180 layui-input" value="${card_id?default('')}" />
 			<input placeholder="五十度id" name ="user_id" class="width180 layui-input" value="${user_id?default('')}" title="不带20开头的." />
 			<input placeholder="评论id" name ="id" class="width180 layui-input" value="${id?default('')}" />
 			<input placeholder="内容" name ="content" class="width180 layui-input" value="${content?default('')}" />
 		</div>
 		<div class="layui-input-inline" >
 			<label class="layui-form-label">地区负责人</label><select name="person" id="person" class="width100 layui-select">
				<option value=""></option>
				<option value="1">袁杰</option>
		        <option value="2">李扬</option>
		        <option value="3">张炜</option>
		        <option value="4">常少彪</option>
		        <option value="100">强制清空</option>
		      </select>
 			<button class="layui-btn" lay-submit=""> <span class="fa fa-search"></span> 查询</button>
 			<a class="layui-btn" id="del_x"><span class="fa fa-trash"></span>删除</a>
 			<a class="layui-btn" id="ignore_x" title="下次不会出现"><span class="fa fa-wrench"></span>一键忽略</a>
 		</div>
    </form>
 	
</blockquote> 

<table class="layui-table" >
	<thead>
       <tr>
            <th><input type="checkbox" id="all" >评论id</th>
            <th>用户</th>
            <th>用户id</th>
            <th>sex</th>
            <th>省份</th>
            <th>类别</th>
            <th width="200px">评论内容</th>
<!--             <th>状态</th> -->
            <th>帖子</th>
            <th class="content">帖子内容</th>
            <th>评论时间</th>
<!--             <th>会员到期</th> -->
            <th>操作</th>
        </tr>
     </thead>
     <tbody>
     <#list page.list as one>
     <tr>
     	<td><input type="checkbox" name="id" value="${one.id}" />${one.id}</td>
<!--<#if one.content?length gt 10>${one.content?substring(0,10)}...<#else>${one.content}</#if> -->
     	<td><#if one.vip_end_time gt now  ><span style="color:#FFD700;font-size:18px;">♛</span></#if><script>document.write(decodeURIComponent("${one.nick_name?default('')}"));</script></td>
     	<td><a href="${base}/users_list/detail?user_id=${one.user_id}" target="_blank">${one.user_id?default('')}</a></td>
     	<td>${one.sex_name?default('')}</td>
     	<td>${one.area_name?default('')}</td>
     	<td>${one.is_true_name}</td>
     	<td title="${one.content}" width="200px">${one.content}</td>
<!--      	<td >${one.is_discuss}</td> -->
     	<td><a href="${base}/card_list/detail?id=${one.card_id}" target="_blank" >${one.card_id}</a></td>
     	<td class="content"><script>
     	var text${one.id} = decodeURIComponent("${one.card_content?default('')}");
     	document.write(text${one.id}.substring(0,22));</script></td>
     	<td>${one.create_time_string} </td>
<!--      	<td><#if one.vip_end_time?? ><#if one.vip_end_time gt 0 >${one.vip_end_time_string?default('')}</#if></#if> </td> -->
     	<td><a onclick="del(${one.id});" ><span class="fa fa-trash"></span></a> <a onclick="follow(${one.id});" title="关注" ><span class="fa fa-eye"></span></a>
     	<a onclick="discuss(${one.id});" title="回复帖子评论"><span class="fa fa-comments-o"></span> 回复</a>
     	</td>
     </tr>
     </#list>
     </tbody>
</table>
<div id="pageDiv"></div>
<form action="${base}/util/uploadFile" method="post" name="uploadForm" enctype="multipart/form-data" id="uploadForm" class="hide" >
    <input name="pic" type="file" id="pic" class="hide"/>
</form>
</body>
<script src="${base}/js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="${base}/layui/layui.all.js"></script>
<script type="text/javascript">
$("#is_true").val('${is_true?default('')}');
$("#sex").val('${sex?default('')}');
$("#person").val('${person?default('')}');
$("#type").val('${type?default('0')}');

$("#all").click(function (){
	if ($("#all").prop("checked")) {
		$("input[type='checkbox']").prop("checked", true);
	} else {
		$("input[type='checkbox']").prop("checked", false);
	}
});

function discuss(id){
	layer.open({
	    type: 1 ,
	    title: '帖子' + id +'评论',   //标题
	    area: ['600px', '400px'],   //宽高
	    shade: 0.4,   //遮罩透明度
	    content: $("#discuss"),
	    btn: ['确定'], //按钮组
	    scrollbar: false ,//屏蔽浏览器滚动条
	    yes: function(index){
	    	var content = $("#content").val();
	    	if (content){
	    		$.post("${base}/card_list/fastGiveDiscuss",
				   		{"id":id,"content":content},function(data){ 
				   			layer.msg(data);
				   			$("#discuss").hide();
				   		}
				 );	
	    	}
	        layer.close(index);
	        $("#discuss").hide();
	    },
		cancel: function(){
			$("#discuss").hide();        
	    }
	});
}


layui.use('laypage',function () {
    var laypage = layui.laypage ;
    laypage.render({
        elem:"pageDiv",
        count:${page.totalPage*15},
        limit:15,
        curr:${page.pageNumber},
        layout:['count','prev','page','next','skip'],
        jump:function (obj,first) {
            var page = obj.curr;
            if(!first){
                $("#page").val(page);
                $("#dataForm").submit();
            }
        }
    });
});


var _id = 0 ;
$('body').bind('keyup', function(event) {
	　　if (event.keyCode == "13") {
	　　　　//回车执行查询
	　　　　_del();
	　　}
});
	
function _del(){
	console.log("_del " + _id);
	if (_id > 0 ){
		$.post("${base}/card_list/discuss_del",
		   		{"id":_id},function(data){ 
		   			layer.msg(data);
		   			window.location.reload();
		   		}
		    );
	}
}


function del(id){
	_id = id;
	//询问框
	layer.confirm('确定要删除吗？', {
	  btn: ['确定'] //按钮
	}, function(){
		_del();
	});
}


function follow(id){
	layer.prompt({title: '请输入关注数量，并确认', formType: 2}, function(content, index){
		$.post("${base}/card_list/giveFollow",
		   		{"id":id,"num":content},function(data){ 
		   			layer.msg(data);
		   		}
		    );
		layer.close(index);
    });	
}

$("#del_x").click(function(){
	 try {
		 var ids = "";
			$('input[name="id"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
				ids = ids + $(this).attr("value")+",";
		    });
			if(ids){
				$.post("${base}/card_list/discuss_del_select",
				   		{"ids":ids},function(data){ 
				   			layer.msg(data);
				   			window.location.reload();
				   		}
				    );
			}
    }catch(e) {
       console.log(e)
    }
});

$("#ignore_x").click(function(){
	 try {
		 var ids = "";
			$('input[name="id"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
				ids = ids + $(this).attr("value")+",";
		    });
			if(ids){
				$.post("${base}/card_list/discuss_ignore_select",
				   		{"ids":ids},function(data){ 
				   			layer.msg(data);
				   			window.location.reload();
				   		}
				    );
			}
   }catch(e) {
      console.log(e)
   }
});


</script>
</html>